using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Input.Touch;

namespace Perovich.GameObjects.TwoDimensional
{

    /// <summary>
    /// The <see cref="TextureSpriteObject2D"/> is a <see cref="DrawableObject2D"/> that draws itself using a <see cref="Texture2D"/>.
    /// </summary>
    public class TextureSpriteObject2D : DrawableObject2D
    {
        /// <summary>
        /// Gets or sets the origin of the <see cref="Texture2D"/> used for drawing
        /// </summary>
        public Vector2 Origin
        {
            get { return _origin; }
            set { _origin = value; }
        }


        /// <summary>
        /// Gets or sets the <see cref="Texture2D"/> use to draw this <see cref="TextureSpriteObject2D"/>.
        /// </summary>
        public Texture2D Texture
        {
            get;
            set;
        }

        /// <summary>
        /// Constructs a new instance of the <see cref="TextureSpriteObject2D"/> class.
        /// </summary>
        /// <param name="game"><see cref="Perovich.GameObjects.Interfaces.ICanHoldComponents"/> instance that this <see cref="TextureSpriteObject2D"/> will be constructed for.</param>
        public TextureSpriteObject2D(Interfaces.ICanHoldComponents game)
            : base(game)
        {
            _origin = Vector2.Zero;
        }


        /// <summary>
        /// Alows the <see cref="TextureSpriteObject2D"/> to draw itself
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        public override void Draw(GameTime gameTime)
        {
            if (Texture != null)
            {
                SBatches.CurrentBatch.Draw(Texture, new Rectangle((int)(Position).X, (int)(Position).Y, Texture.Width, Texture.Height), null, Color.White, Rotation, Origin, SpriteEffects.None, Depth);
            }
            else
            {
                if (System.Diagnostics.Debugger.IsAttached)
                {
                    System.Diagnostics.Debugger.Break();
                }
            }
            base.Draw(gameTime);
        }

        private Vector2 _origin;
    }
}
